<?php

// +----------------------------------------------------------------------
// | author: admin
// +----------------------------------------------------------------------

namespace app\adminapi\lists\order;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\order\Order;
use app\common\lists\ListsSearchInterface;


/**
 * Order列表
 * Class OrderLists
 * @package app\adminapi\listsorder
 */
class OrderLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author admin
     * @date 2025/04/29 17:52
     */
    public function setSearch(): array
    {
        return [
            '=' => ['order_no', 'order_type', 'user_id', 'people_num', 'baggage_num', 'line_id', 'driver_id', 'car_num', 'estimated_time', 'actual_time', 'start_address', 'end_address', 'way_address', 'people_name', 'people_phone', 'verify_code', 'pay_type', 'pay_time', 'price', 'order_status', 'refund_status', 'refund_price', 'refund_time', 'cancel_type', 'cancel_desc', 'cancel_time', 'cancel_reason', 'complete_time', 'complete_desc'],
        ];
    }


    /**
     * @notes 获取列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author admin
     * @date 2025/04/29 17:52
     */
    public function lists(): array
    {
        return Order::where($this->searchWhere)
            ->field(['id', 'order_no', 'order_type', 'user_id', 'people_num', 'baggage_num', 'line_id', 'driver_id', 'car_num', 'estimated_time', 'actual_time', 'start_address', 'end_address', 'way_address', 'people_name', 'people_phone', 'verify_code', 'pay_type', 'pay_time', 'price', 'order_status', 'refund_status', 'refund_price', 'refund_time', 'cancel_type', 'cancel_desc', 'cancel_time', 'cancel_reason', 'complete_time', 'complete_desc'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order(['id' => 'desc'])
            ->select()
            ->toArray();
    }


    /**
     * @notes 获取数量
     * @return int
     * @author admin
     * @date 2025/04/29 17:52
     */
    public function count(): int
    {
        return Order::where($this->searchWhere)->count();
    }

}